package com.winchain.provider;

import com.shell.bee.base.utils.StringUtil;
import com.shell.customer.feign.CustomerFeign;
import com.shell.customer.po.CusRec;
import com.winchain.chainbill.receivables.base.service.ArRecordEbService;
import com.winchain.ebon.po.ArRecordEb;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SyncArRecordEbProvider {
	@Autowired
	private ArRecordEbService arRecordEbService;
	@Autowired
	private CustomerFeign customerFeign;

	@RequestMapping({ "/ebon-chainbill/sync-acct-receivable" })
	public String syncArRecord(@RequestBody ArRecordEb ar) {
		if (StringUtil.emptyAndNull(ar.getCstId())) {
			return "��������Id����";
		}
		CusRec cr = this.customerFeign.selectCusById(ar.getCstId());
		if (cr == null) {
			return "����������������������";
		}
		int count = this.arRecordEbService.save(ar);
		if (count <= 0) {
			return "����������������";
		}
		return "success";
	}
}
